package Messages;

import java.io.IOException;
import java.sql.SQLException;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * this class implements editing edition number of book in db
 * @author Ron Shenkerman
 * @author Gabi Revah
 * @author Aviad Almog
 * @author Ivan Onyshchenko
 */
public class MessageEditEditionNum {
	private ConnectionToClient client;
/**
 * constractor of this class 
 * @param client
 */
	public MessageEditEditionNum(ConnectionToClient client) {
		super();
		this.client=client;
		}
/**
 * edit edition number in DB 
 * @param str
 * @throws SQLException
 * @throws IOException
 */
	public void EditEditionNum(String[] str) throws SQLException, IOException {
		System.out.println("Getting new edition number");

		SQLConnection sc = new SQLConnection();
		java.sql.PreparedStatement ps = sc.getConnection().prepareStatement("Update DB1.books SET EditionNumber=? WHERE ID=?");
		ps.setString(1, str[2]);
		ps.setString(2, str[1]);
		ps.executeUpdate();
		client.sendToClient("EditEditionNum");
	
		ps.close();		
	}

}
